#include "stdafx.h"
#include "Geometry.h"

using namespace patiya::geom;

// ----------------------------------------------------------------------------
// Point
//

Point::Point(int x, int y)
    : m_x(x), m_y(y)
{}

Point::Point(const Point& pos)
    : m_x(pos.m_x), m_y(pos.m_y)
{}

bool Point::operator==(const Point& other) const
{
    return (m_x == other.m_x && m_y == other.m_y);
}

Point& Point::operator=(const Point& other)
{
    m_x = other.m_x;
    m_y = other.m_y;
    return *this;
}

Point& Point::operator+=(const Point& other)
{
    m_x += other.m_x;
    m_y += other.m_y;
    return *this;
}

int Point::x() const { return m_x; }
int Point::y() const { return m_y; }

int& Point::rX() { return m_x; }
int& Point::rY() { return m_y; }

void Point::x(const int value) { m_x = value; }
void Point::y(const int value) { m_y = value; }

// ----------------------------------------------------------------------------
// Size
//

Size::Size(int width, int height)
    : m_width(width), m_height(height)
{}

Size::Size(const Size& size)
    : m_width(size.m_width), m_height(size.m_height)
{}

bool Size::operator==(const Size& other) const
{
    return (m_width == other.m_width && m_height == other.m_height);
}

Size& Size::operator=(const Size& other)
{
    m_width  = other.m_width;
    m_height = other.m_height;
    return *this;
}

int Size::width()  const { return m_width; }
int Size::height() const { return m_height; }

int& Size::rWidth()  { return m_width; }
int& Size::rHeight() { return m_height; }

void Size::width(const int value)  { m_width = value; }
void Size::height(const int value) { m_height = value; }

// ----------------------------------------------------------------------------
// Rect
//

Rect::Rect(const Point& pos, const Size& size)
    : m_pos(pos), m_size(size)
{}

Rect::Rect(const Rect& rect)
    : m_pos(rect.m_pos), m_size(rect.m_size)
{}

bool Rect::operator==(const Rect& other) const
{
    return (m_pos == other.m_pos && m_size == other.m_size);
}

Rect& Rect::operator=(const Rect& other)
{
    m_pos  = other.m_pos;
    m_size = other.m_size;
    return *this;
}

const Point& Rect::pos()  const { return m_pos; }
const Size&  Rect::size() const { return m_size; }

Point& Rect::rPos()  { return m_pos; }
Size&  Rect::rSize() { return m_size; }

void Rect::pos(const Point& value) { m_pos = value; }
void Rect::size(const Size& value) { m_size = value; }